<template>
  <div class="detail_container">
    <div class="head_title" v-if="!detailForm.id">创建体检信息</div>
    <div class="head_title" v-else-if="detailForm.id && isEdit">编辑体检信息</div>
    <div class="head_title" v-else-if="detailForm.id && !isEdit">查看体检信息</div>
    <el-divider></el-divider>
    <div class="px-20">
      <el-form :model="params" :disabled="detailForm.id && !isEdit" ref="expertForm"  label-width="75px" :rules="rules" label-position="left" size="small">


        <el-row :gutter="15">
          <el-col :lg="8" :xl="6">
            <el-form-item label="报告时间" prop="heathCheckDate">
              <el-input v-model="params.heathCheckDate" placeholder="请输入报告时间" />
            </el-form-item>
          </el-col>



          <el-col :lg="8" :xl="6">
            <el-form-item label="主检建议" prop="heathMhkAdv">
              <el-input v-model="params.heathMhkAdv" placeholder="请输入主检建议" />
            </el-form-item>
          </el-col>
        </el-row>



        <el-row :gutter="15">
          <el-col :lg="8" :xl="6">
            <el-form-item label="体检结果" prop="heathBhkRst">
              <el-input v-model="params.heathBhkRst" type="textarea" autosize placeholder="请输入体检结果" />
            </el-form-item>
          </el-col>



          <el-col :lg="8" :xl="6">
            <el-form-item label="体检结论" prop="heathVerDict">
              <el-input v-model="params.heathVerDict" placeholder="请输入体检结论" />
            </el-form-item>
          </el-col>
        </el-row>



        <el-row :gutter="15">
          <el-col :lg="8" :xl="6">
            <el-form-item label="体检状态" prop="heathStatus">
              <el-select v-model="params.heathStatus"  placeholder="请选择体检状态" style="width: 100%;" >
                <el-option
                  v-for="dict in heathStatusOption"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>



          <el-col :lg="8" :xl="6">
            <el-form-item label="姓名" prop="realName">
              <el-input v-model="params.realName" placeholder="请输入姓名" />
            </el-form-item>
          </el-col>
        </el-row>



        <el-row :gutter="15">
          <el-col :lg="8" :xl="6">
            <el-form-item label="工作岗位" prop="postName">
              <el-input v-model="params.postName" placeholder="请输入工作岗位" />
            </el-form-item>
          </el-col>



          <el-col :lg="8" :xl="6">
            <el-form-item label="联系电话" prop="mobile">
              <el-input v-model="params.mobile" placeholder="请输入联系电话" />
            </el-form-item>
          </el-col>
        </el-row>



        <el-row :gutter="15">
          <el-col :lg="8" :xl="6">
            <el-form-item label="身份证号" prop="idcardNo">
              <el-input v-model="params.idcardNo" placeholder="请输入身份证号" />
            </el-form-item>
          </el-col>



          <el-col :lg="8" :xl="6">
            <el-form-item label="机构名称" prop="organName">
              <el-input v-model="params.organName" placeholder="请输入机构名称" />
            </el-form-item>
          </el-col>
        </el-row>



        <el-row :gutter="15">
          <el-col :lg="8" :xl="6">
            <el-form-item label="机构编码" prop="organCode">
              <el-input v-model="params.organCode" placeholder="请输入机构编码" />
            </el-form-item>
          </el-col>



          <el-col :lg="8" :xl="6">
            <el-form-item label="企业统一信用码" prop="creditCode" label-width="120px">
              <el-input v-model="params.creditCode" placeholder="请输入企业统一信用码" />
            </el-form-item>
          </el-col>
        </el-row>



        <el-row :gutter="15">
          <el-col :lg="8" :xl="6">

            <el-form-item label="机构子类型编码" prop="organSubType" label-width="120px">
              <el-select v-model="params.organSubType"  placeholder="请选择机构子类型编码" style="width: 100%;" >
                <el-option
                  v-for="dict in dict.type.organ_sub_type"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>



          <el-col :lg="8" :xl="6">
            <el-form-item label="机构地址" prop="organAddress">
              <el-input v-model="params.organAddress" placeholder="请输入机构地址" />
            </el-form-item>
          </el-col>
        </el-row>


      </el-form>
    </div>
    <div class="flex p-20">
      <!--<el-button @click="sureForm('expertForm')" type="primary" v-if="!detailForm.id || isEdit">确认提交</el-button>
      <el-button @click="isEdit = true" type="primary" v-if="detailForm.id && !isEdit">编辑</el-button>-->
      <el-button @click="show = false">返回</el-button>
    </div>
  </div>
</template>

<script>
  export default{
    dicts: ['heath_status','organ_sub_type'],
    data () {
      return {
        params:{
            id: null,
            heathCheckDate: null,
            heathMhkAdv: null,
            heathBhkRst: null,
            heathVerDict: null,
            heathStatus: null,
            realName: null,
            postName: null,
            mobile: null,
            idcardNo: null,
            organName: null,
            organCode: null,
            creditCode: null,
            organSubType: null,
            organAddress: null,
            createBy: null,
            createTime: null,
            updateId: null,
            updateBy: null,
            updateTime: null,
            delFlag: null,
        },
        rules: {
        },
        heathStatusOption: [
          {
          label: "合格",
          value: 1
        },
          {
          label: "不合格",
          value: 2
        },
        ]
      }
    },
    props: {
      editVisible: {
        type: Boolean,
        default: () => {
          return false
        }
      },
      detailForm: {
        type: Object,
        default: () => {
          return {}
        }
      },
      isEdit:{
        type:Boolean,
        default:()=>{
          return false
        }
      },
    },
    watch:{

    },
    computed: {
      show: {
        get () {
          return this.editVisible
        },
        set (val) {
          this.$emit('update:editVisible', val)
        }
      },
    },
    created () {
      if(this.detailForm.id){
        this.params = {...this.detailForm}
      }
    },
    methods: {
      // 确认
      sureForm(formName) {
        this.$refs [formName].validate((valid) => {
          if (valid) {
            if(this.detailForm.id){
              this.$emit('submitForm', this.params,this.detailForm.id)
            }else{
              this.$emit('submitForm', this.params)
            }
          } else {
            console.log('error submit!!');
            return false;
          }
        });

      },
    }

  }
</script>

<style scoped="scoped" lang="scss">
  .titile_txt{
    font-family: Source Han Sans SC, Source Han Sans SC;
    font-weight: bold;
    font-size: 16px;
    color: #333333;
    line-height: 19px;
    margin-bottom: 15px;
  }
</style>
